const HtmlWebpackPlugin = require("html-webpack-plugin"); // 使页面真正运行起来

module.exports = {
  mode: "none",
  entry: "./src/index.jsx",
  module: {
    rules: [
      {
        test: /\.jsx$/,
        loader: "babel-loader",
        options: {
          // presets: [
          //   "@babel/preset-react",
          //   {
          //     "runtime": "automatic", // 自动引入import React from "react";
          //   },
          // ],
          presets: [
            [
              "@babel/preset-react",
              {
                runtime: "automatic",
              },
            ],
          ],
        },
      },
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"],
      },
    ],
  },
  devServer: {
    hot: true,
    open: true,
  },
  plugins: [
    new HtmlWebpackPlugin({
      templateContent: `
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Webpack App</title>
  </head>
  <body>
    <div id="app" />
  </body>
</html>
    `,
    }),
  ],
};
